package domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.OneToMany;

@Entity
@DiscriminatorValue("driver")
public class Driver extends Role implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Enumerated(EnumType.STRING)
	private Route routeArea; // It should have many routes
	
	@OneToMany
	private List<Schedule> schedules = new ArrayList<Schedule>();
	
	public Route getRouteArea() {
		return routeArea;
	}

	public void setRouteArea(Route routeArea) {
		this.routeArea = routeArea;
	}

	public List<Schedule> getSchedules() {
		return schedules;
	}

	public void addSchedules(Schedule schedule) {
		this.schedules.add(schedule);
	}
	
	public List<Schedule> getNotPassedSchedules() {
		List<Schedule> scheduleList = new ArrayList<Schedule>();
        for(int i=0; i<schedules.size(); i++){
        	Schedule s = schedules.get(i);
        	if(!s.isItPassedSchedule() && !s.getStatus().equals(ScheduleStatus.unpriortized) && !s.getStatus().equals("")){
        		scheduleList.add(s);
        	}
        }
		return scheduleList;
	}
	
}
